import request from '@/config/axios'
import type { UserType } from './types'
import {Str} from "windicss/types/lang/tokens";

interface RoleParams {
  roleName: string
}

export const loginApi = (params: UserType): Promise<IResponse<UserType>> => {
  return request.post({ url: '/api/login', params })
}
export const user = (str: String): Promise<IResponse<UserType>> => {
  return request.post({ url: '/api/getEnabled', params:{str} })
}
export const uppassword = (id: String,newpwd: String): Promise<IResponse<UserType>> => {
    return request.post({ url: '/api/account/updUserPwd', params:{id,newpwd} })
}

/* 上传文件 */
export const mainImage = (params: any): Promise<IResponse> => {
    return request.post({ url: 'http://localhost:8081/upload/mainImage', params })
}
export const loginOutApi = (): Promise<IResponse> => {
  return request.get({ url: '/user/loginOut' })
}

export const getUserListApi = ({ params }: AxiosConfig) => {
  return request.get<{
    total: number
    list: UserType[]
  }>({ url: '/user/list', params })
}

export const getAdminRoleApi = (
  params: RoleParams
): Promise<IResponse<AppCustomRouteRecordRaw[]>> => {
  return request.get({ url: '/role/list', params })
}

export const getTestRoleApi = (params: RoleParams): Promise<IResponse<string[]>> => {
  return request.get({ url: '/role/list', params })
}
